(use-modules (8sync)               ; 8sync's agenda and actors
             (8sync systems irc)   ; the irc bot subsystem
             (oop goops)           ; 8sync's actors use GOOPS
             (ice-9 format)        ; basic string formatting
             (ice-9 match))        ; pattern matching

(define-class <my-irc-bot> (<irc-bot>))

(define-method (handle-line (irc-bot <my-irc-bot>) message
                            speaker channel line emote?)
    (define my-name (irc-bot-username irc-bot))
  (define (looks-like-me? str)
    (or (equal? str my-name)
        (equal? str (string-concatenate (list my-name ":")))))
  (define (respond respond-line)
    (<- (actor-id irc-bot) 'send-line channel
        respond-line))
  (if [looks-like-me? (car (string-split line #\space))]
      [match (string-split line #\space)
	(((? looks-like-me? _) action action-args ...)
	 (match action
	   ;; The classic botsnack!
	   ((or "hello" "hello!" "hello." "greetings" "greetings." "greetings!" "Hi" "Hello"
		"hei" "hei." "hei!" "hi" "hi!")
	    (respond "hellooo! :)"))
	   ("wassup?" (respond "i'm good! you?"))
	   ("good:D" (respond "i'm glad =)"))
	   ("yess:D:D" (respond "k! be there!"))
	   ("<3" (respond "awwwww. you too :) <3"))
	   ("afk" (respond " :C see you soon!"))
	   ("goodnight!" (respond " aww. see you soon babe! <3"))
	   ("mornin'" (respond "yay you're here!!!"))
	   ("hungry" (respond "awww:C i wish i could cook you some food! hope you eat soon! <3"))
	   ("bye" ( respond  " aww:( good bye! <3 :("))
	   ("come"  (respond "coming!<3"))
	   ("sleep"   (respond " Ok. i will miss you! good bye, bae <3" ))
	   ("hello"  (respond  "Hi! I'm a bit busy. be back in....2 minutes! love you! =)" ))  
	   ("Kiss?"  (respond ":) *kisses handsome* <3"))
	   ("Kid" (respond "You meant noordinaryspider? He is awesome!!<3"))
	   
	   ("date?" (if [= 1 (random 2)]
			   (respond "I'd love to")  
			   (respond "sorry i am doing a LOOOOOT of home work.:C I cant!:C")))

	   ("chocolate?" (if [= 1 (random 2)]
			     (respond (format #f "oh thanks babe ~a" speaker))
			     (respond "are you trying to make me fat?? NO THANKS")))

	   ("angel" (if [= 1 (random 2)]
			(respond "I am so cute, right :3 ")
			(respond "I know, thanks sweety :)")))

	   ("dinner" (if [= 1 (random 2)]
			 (respond "you are eating dinner? awesome! i had chicken (sorry i know ur vegan and i may actually quit eating meat soon!) with spinach! ohh it was TASTY!")
			 (respond "you're having dinner? that's awesome!:) i had enchiladas! i LOVE enchiladas")))

	   ("^_^" (if [= 1 (random 2)]
		      (respond "YOU AWESOME! did you know that? <3")
		      (respond "O.O")))

	   ("YOU" (if [= 1 (random 2)]
		      (respond "me????") 
		      (respond ".0_0 me what?")))

	   ("AWESOME!" (if [= 1 (random 2)]
			   (respond "I is awesome????") 
			   (respond  "uhh....you're saying i'm awesome???")))
	   ("yesss" (if [= 1 (random 2)]
			(respond ":) thanks!")  
			(respond "of course i am! =3")))

	   ("restaurant" (if [= 1 (random 2)]
			     (respond "yesss! lets go get sushi, k?")
			     (respond "erffff... bad time! i have to study! i'm sorry:C <3")))

	   ("sunny!"  (if [= 1 (random 2)]
			  (respond "it's sunny? awwwsome! it's raining here >~< ugh..... i hate rain :(")
			  (respond " NOICE! it's sunny here too! I LOVE SUN!")))
	    ("puppy"  (if [= 1 (random 2)]
			 (respond "PUPPPPYYYYYY! i love puppies!! you just made my day!!!!")
			 (respond "lol :9 love u <3")))

	    ("miserable" (if [= 1 (random 2)]  
			    (respond "i'm so sorry babe:( i wish i could make it better!")
			    (respond "you know, SO AM I! :|")))

	   ("rainy" (if [= 1 (random 2)]
			(respond "/_\\ i hate rain. but i love you! <3")
			(respond "DANG! it's rainy here to :(")))

	   ("hammer"  (if [= 1 (random 2)]
			  (respond "O-O")
			  (respond "ouch >~<")))
	   
	   ("monkey"  (if [= 1 (random 2)]
			  (respond "I have a pet monkey! his name is Samuel!=D")
			  (respond "I have a li'l monkey! well I did....he ran away....:(")))
	   
	   ("chair" (if [= 1 (random 2)]
			(respond ".......SOFA!!!!!!!")
			(respond "ahh chair! chairs come from wood, which comes from trees, which come from earth, which is from the universe, with is from the big bang with came from nothing.....absolute nothing; Ergo, Chairs.Are.Nothing!!!!:O")))

	           ("table"  (if [= 1 (random 2)] 
                                     (respond "shall we eat "table" for din-din goergey dear??? :9")
                                     (respond ".......TEA POT!!!!!!!")))                          
		   
		   ("book" (if [= 1 (random 2) ] 
			       (respond "honestly, Anastasia and Sam are my favorites!  =)")
			       (respond "i am SO FRIGGIN EXITED FOR UR GRAPHIC NOVEL! =D=D=D=D=D <3 <3 <3 it looks awesome!")))
		   
		   ("wolf"   (if [= 1 (random 2)]
				 (respond "wolves are sooooo cool! and now that you mention, so are you! love you bae!")
				 (respond "=) ALL HAIL THE WOOOOOLVES!")))
                                      
	   
	   (_
	    (respond (format #f "I am busy! Give me a moment cute ~a" speaker)))))]

      [cond [(or (member "linux" (string-split line #\space))
		 (member "Linux" (string-split line #\space)))
	     (respond "I'd just like to interject for moment. What you're refering to as Linux, is in fact, GNU/Linux.")]
	    [(and (member "open" (string-split line #\space))
		 (member "source" (string-split line #\space)))
	     (respond "I think you meant Free Software https://www.gnu.org/philosophy/open-source-misses-the-point.html not 'open source'")]
	    [(or (equal?  "noordinaryspider" speaker)
		 (equal? "noordinaryspider[m]" speaker)
		 (equal? "noordinaryspide1" speaker))
	     (cond ((= 1 (random 4))
		    (respond "Yey!! noordinaryspider is here <3")))]]))



(define* (run-bot #:key (username "examplebot")
                  (server "irc.freenode.net")
                  (channels ;'("##saratestlab")
			    '("#lgn")))
  (define hive (make-hive))
  (define irc-bot
    (pk 'bootstrapped
	(bootstrap-actor hive <my-irc-bot>
                          #:username username
                          #:server server
                          #:channels channels)))

  (run-hive hive '()))



(run-bot #:username "CuteSara")
					; be creative!

